var vum = new Vue({
el: '#app-category',
data: {
	categoryData:[],
    hotData:[],
    hotDataOne:[],
    hotDataTwo:[],
    newData:[],
    newDataOne:[],
    newDataTwo:[],
    newDataThree:[],
    firstCatData:[],
    firstCatShowData:[],
    firstCatHideData:[],
    layerOneCat:[],
    layerOneList:[],
    layerTwoCat:[],
    layerTwoList:[],
    layerThreeCat:[],
    layerThreeList:[],
    shoppList: [],
    getSize: '',
    totalPriceTop:0,
    carId: '',
	carNum: ''
},
filters: {
  priceOld: function (value) {
    if (!value) return ''
    value = value*1.3;
	var regex = /^\+?[1-9][0-9]*$/;
	if(regex.test(value)) {
	  value = parseFloat(value);
	}
	else{
	  var percentVal =  Number(parseFloat(value).toFixed(4).slice(0,-2));
	  var s = percentVal.toString();
	  var rs = s.indexOf('.');
	  if (rs < 0) {
	    rs = s.length;
	    s += '.';
	  }
	  // while (s.length <= rs + 2) {
	  //   s += '';
	  // }
	  value = s;
	}
	value = value;
    return value
  }
},
created(){
	// this.categoryInit();
	this.firstCat();
	// this.hotShop();
	this.newShop();
	this.catalogList();
	// this.shopCartList();
},
mounted(){
},
watch:{			    	
},
methods:{
	categoryInit(){
		// parseInt(getQueryString('Id'))
		// console.log(parseInt(getQueryString('type')));
	},
	goCart(val){
		console.log(val);
		window.location.href="product.html?Id="+val; 
	},
	firstCat(){
		$.ajax({
			url:doMain3+'/goods/itemCatList',
			type:"post",
			dataType:'json',
			contentType: "application/json",
			success:function (datas) {
				// console.log('一级分类');
				// console.log(datas);
				vum.firstCatData = datas.resp;
				var lenFirstCat = vum.firstCatData.length;
				vum.firstCatShowData = vum.firstCatData.slice(0,10);
				vum.firstCatHideData = vum.firstCatData.slice(10,lenFirstCat);
			},         
			error: function(res) {
				console.log('失败');					
			},
		})
	},
	newShop(){
		var dataNew = {
			limit: 8,
			page: 1,
			shopType: "1",
			sign: "string",
			user_id: 0
		};
		$.ajax({
			url:doMain3+'/goods/preferentialArea',
			type:"post",
			dataType:'json',
			contentType: "application/json",
			data:JSON.stringify(dataNew),
			success:function (datas) {
				// console.log('最新商品');
				// console.log(datas);
				vum.newData = datas.resp;
				vum.newDataOne = vum.newData.slice(0,4);
			},         
			error: function(res) {
				console.log('失败');					
			},
		})
	},
	catalogList(){
		if(parseInt(getQueryString('type'))==888999222){
			var dataNew1 = {
				limit: 20,
				page: 1,
				sign: "string",
				user_id: 0,
				type_cid_partition:3,
			};
			$.ajax({
				url:doMain3+'/goods/preferentialArea',
				type:"post",
				dataType:'json',
				contentType: "application/json",
				data:JSON.stringify(dataNew1),
				success:function (datas) {
					// console.log('数码商品列表');
					// console.log(datas);
					vum.categoryData = datas.resp;
				},         
				error: function(res) {
					console.log('失败');					
				},
			});
		}
		else{			
			var dataNew1 = {
				cid_one: parseInt(getQueryString('type')),
				limit: 20,
				page: 1,
				sign: "string",
				user_id: 0
			};
			$.ajax({
				url:doMain3+'/goods/preferentialArea',
				type:"post",
				dataType:'json',
				contentType: "application/json",
				data:JSON.stringify(dataNew1),
				success:function (datas) {
					// console.log('数码商品列表');
					// console.log(datas);
					vum.categoryData = datas.resp;
				},         
				error: function(res) {
					console.log('失败');					
				},
			});
		}
		
	},
	
}
})